package Veterinaria.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Veterinaria.excepcion.DAOExcepcion;
import Veterinaria.negocio.GestionCita;
import Veterinaria.negocio.GestionFacturaDetalle;

/**
 * Servlet implementation class EliminarDetalleFacturaServlet
 */
@WebServlet("/EliminarDetalleArticuloServlet")
public class EliminarDetalleArticuloServlet extends
		javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public EliminarDetalleArticuloServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

		String idcita = request.getParameter("txtCita");
		String idpaciente = request.getParameter("txtIdpaciente");
		String paciente = request.getParameter("txtPaciente");
		String iddoctor = request.getParameter("txtIddoctor");
		String doctor = request.getParameter("txtDoctor");
		String seltipocita = request.getParameter("selTipocita");
		String selestadocita = request.getParameter("selEstadoCita");
		String direccion = request.getParameter("txtDireccion");
		String fecha = request.getParameter("txtFecha");
		String hora = request.getParameter("txtHora");
		String notas = request.getParameter("txtNotas");
		String id = request.getParameter("id");

		GestionCita cita = new GestionCita();

		try {
			cita.eliminarcitaTemporal(id);

		} catch (DAOExcepcion e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}


		try {
			request.setAttribute("detallecita", cita.listartemporal());
		} catch (DAOExcepcion e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		request.setAttribute("var1", idcita);
		request.setAttribute("var2", idpaciente);
		request.setAttribute("var3", paciente);
		request.setAttribute("var4", iddoctor);
		request.setAttribute("var5", doctor);
		request.setAttribute("var6", seltipocita);
		request.setAttribute("var7", selestadocita);
		request.setAttribute("var8", direccion);
		request.setAttribute("var9", fecha);
		request.setAttribute("var10", hora);
		request.setAttribute("var11", notas);
		
		RequestDispatcher rd = request
				.getRequestDispatcher("modificar_cita.jsp");
		rd.forward(request, response);

	}

}
